package cc.smarnet.caihou.phone.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.GridView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import cc.smarnet.caihou.PrintTagHuaActivity;
import cc.smarnet.caihou.PrintTagActivity;
import cc.smarnet.caihou.R;
import cc.smarnet.caihou.phone.boxes.PrintBoxTagActivity;
import cc.smarnet.caihou.phone.deliver.DeliverActivity2;
import cc.smarnet.caihou.phone.sanhuoin.HarvesInActivity;
import cc.smarnet.caihou.phone.sanhuoout.SanHuoOutActivity;
import cc.smarnet.caihou.phone.sanhuoout.SanHuoOutActivity2;
import cc.smarnet.caihou.phone.scanin.ScanInActivity;
import cc.smarnet.caihou.phone.scanout.ScanOutActivity;

public class HomeFragment extends Fragment {
    private View view;

    private GridView homeGridView;
    private View huabiao;
    private View caiguobiao;
    private View saomacru;
    private View saomacchuu;
    private View kehubiao;
    private View xiangbiao;
    private View maoru;
    private View maochu;

//    private List<Map<String, Object>> data_list;
//    private SimpleAdapter simpleAdapter;
//    private int[] icon = {R.drawable.img_home_bracts, R.drawable.img_home_manual_storage,
//            R.drawable.img_home_manual_retrieval, R.drawable.img_home_print,
//            R.drawable.img_home_storage_check, R.drawable.img_home_scan_retrieval};
//    private String[] iconName = {"花产品", "菜/果标签", "客户标签", "扫码入库", "扫码出库", "箱标签"};


    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.fragment_home, container, false);
        return view;
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        initViews();

        //新建List
//        data_list = new ArrayList<Map<String, Object>>();
        //获取数据
//        setData();
        //新建适配器
        String[] from = {"image", "text"};
        int[] to = {R.id.image, R.id.text};
//        simpleAdapter = new SimpleAdapter(getActivity(), data_list, R.layout.home_item, from, to);
//        配置适配器
//        homeGridView.setAdapter(simpleAdapter);


        huabiao.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), PrintTagHuaActivity.class);
                startActivity(intent);
            }
        });
        caiguobiao.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), PrintTagActivity.class);
                startActivity(intent);
            }
        });

        saomacru.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), ScanInActivity.class);
                startActivity(intent);
            }
        });


        saomacchuu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), ScanOutActivity.class);
                startActivity(intent);
            }
        });
        kehubiao.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), DeliverActivity2.class);
                startActivity(intent);
            }
        });
        xiangbiao.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), PrintBoxTagActivity.class);
                startActivity(intent);
            }
        });
        maoru.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), HarvesInActivity.class);
                startActivity(intent);
            }
        });
        maochu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), SanHuoOutActivity2.class);
//                Intent intent = new Intent(getActivity(), SanHuoOutActivity.class);
                startActivity(intent);
            }
        });


    }

    public void initViews() {
        huabiao = view.findViewById(R.id.huabiao);
        caiguobiao = view.findViewById(R.id.caiguobiao);
        saomacru = view.findViewById(R.id.saomacru);
        saomacchuu = view.findViewById(R.id.saomacchuu);
        kehubiao = view.findViewById(R.id.kehubiao);
        xiangbiao = view.findViewById(R.id.xiangbiao);
        maoru = view.findViewById(R.id.maoru);
        maochu = view.findViewById(R.id.maochu);
    }

//    public void setData() {
//        //icon和iconName的长度是相同的，这里任选其一都可以
//        for (int i = 0; i < icon.length; i++) {
//            Map<String, Object> map = new HashMap<String, Object>();
//            map.put("image", icon[i]);
//            map.put("text", iconName[i]);
//            data_list.add(map);
//        }
//    }
}

